package com.sanji.sjmallutils;

import android.content.Context;
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;

/**
 * 权限检查工具类
 * Created by zsf on 17-4-15.
 */

public class PermissionsChecker {

    private Context mCtx;

    public PermissionsChecker(Context context){
        mCtx = context.getApplicationContext();
    }

    //判断权限集合
    public boolean lacksPermissions(String... permissions){
        for(String permission : permissions){
            if(lacksPermission(permission)){
                return true;
            }
        }
        return false;
    }

    //判断是否缺少权限
    public boolean lacksPermission(String permission){
        return ContextCompat.checkSelfPermission(mCtx,permission) == PackageManager.PERMISSION_DENIED;
    }
}
